{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import numpy as np\n",
    "import time\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn import metrics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#events data is too large , we just should the first 1000000 records.\n",
    "events_data = pd.read_csv(\"./events.csv\",nrows=1000000)\n",
    "#load train data\n",
    "train_data = pd.read_csv(\"./train.csv\")\n",
    "#load test data\n",
    "test_data = pd.read_csv(\"./test.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>lat</th>\n",
       "      <th>lng</th>\n",
       "      <th>c_1</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>684921758</td>\n",
       "      <td>3647864012</td>\n",
       "      <td>2012-10-31T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>244999119</td>\n",
       "      <td>3476440521</td>\n",
       "      <td>2012-11-03T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3928440935</td>\n",
       "      <td>517514445</td>\n",
       "      <td>2012-11-05T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2582345152</td>\n",
       "      <td>781585781</td>\n",
       "      <td>2012-10-30T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1051165850</td>\n",
       "      <td>1016098580</td>\n",
       "      <td>2012-09-27T00:00:00.001Z</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 110 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        event     user_id                start_time city state  zip country  \\\n",
       "0   684921758  3647864012  2012-10-31T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "1   244999119  3476440521  2012-11-03T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "2  3928440935   517514445  2012-11-05T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "3  2582345152   781585781  2012-10-30T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "4  1051165850  1016098580  2012-09-27T00:00:00.001Z  NaN   NaN  NaN     NaN   \n",
       "\n",
       "   lat  lng  c_1   ...     c_92  c_93  c_94  c_95  c_96  c_97  c_98  c_99  \\\n",
       "0  NaN  NaN    2   ...        0     1     0     0     0     0     0     0   \n",
       "1  NaN  NaN    2   ...        0     0     0     0     0     0     0     0   \n",
       "2  NaN  NaN    0   ...        0     0     0     0     0     0     0     0   \n",
       "3  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "4  NaN  NaN    1   ...        0     0     0     0     0     0     0     0   \n",
       "\n",
       "   c_100  c_other  \n",
       "0      0        9  \n",
       "1      0        7  \n",
       "2      0       12  \n",
       "3      0        8  \n",
       "4      0        9  \n",
       "\n",
       "[5 rows x 110 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#change cloumn name  event_id to event , the same as the name in train_data and test data\n",
    "events_data.rename(columns={'event_id':'event'}, inplace = True)\n",
    "\n",
    "events_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>interested</th>\n",
       "      <th>not_interested</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1918771225</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1502284248</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3044012</td>\n",
       "      <td>2529072432</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3044012</td>\n",
       "      <td>3072478280</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3044012</td>\n",
       "      <td>1390707377</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-10-02 15:53:05.754000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp  interested  \\\n",
       "0  3044012  1918771225        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "1  3044012  1502284248        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "2  3044012  2529072432        0  2012-10-02 15:53:05.754000+00:00           1   \n",
       "3  3044012  3072478280        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "4  3044012  1390707377        0  2012-10-02 15:53:05.754000+00:00           0   \n",
       "\n",
       "   not_interested  \n",
       "0               0  \n",
       "1               0  \n",
       "2               0  \n",
       "3               0  \n",
       "4               0  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2877501688</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1776192</td>\n",
       "      <td>3025444328</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1776192</td>\n",
       "      <td>4078218285</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1776192</td>\n",
       "      <td>1024025121</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:01.230000+00:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1776192</td>\n",
       "      <td>2972428928</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-30 11:39:21.985000+00:00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      user       event  invited                         timestamp\n",
       "0  1776192  2877501688        0  2012-11-30 11:39:01.230000+00:00\n",
       "1  1776192  3025444328        0  2012-11-30 11:39:01.230000+00:00\n",
       "2  1776192  4078218285        0  2012-11-30 11:39:01.230000+00:00\n",
       "3  1776192  1024025121        0  2012-11-30 11:39:01.230000+00:00\n",
       "4  1776192  2972428928        0  2012-11-30 11:39:21.985000+00:00"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#shoulds the event data recoard which in train data and test data \n",
    "user_events_data= events_data[events_data['event'].isin(train_data['event'])]\n",
    "user_train_data=train_data[train_data['event'].isin(user_events_data['event'])]\n",
    "user_test_data=test_data[test_data['event'].isin(user_events_data['event'])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3118, 110)\n",
      "(5317, 6)\n",
      "(1819, 4)\n"
     ]
    }
   ],
   "source": [
    "print(user_events_data.shape)\n",
    "print(user_train_data.shape)\n",
    "print(user_test_data.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "user_train_data=user_train_data.join(user_events_data.set_index('event'),on='event',how='left').dropna() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "user_test_data=user_test_data.join(user_events_data.set_index('event'),on='event',how='left').dropna() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>interested</th>\n",
       "      <th>not_interested</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>29002074</td>\n",
       "      <td>3743521539</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-17 19:43:28.249000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4145324389</td>\n",
       "      <td>2013-01-01T03:00:00.003Z</td>\n",
       "      <td>Elizabeth</td>\n",
       "      <td>NJ</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164</th>\n",
       "      <td>38985694</td>\n",
       "      <td>364913652</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-12-01 17:31:05.504000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>405625535</td>\n",
       "      <td>2012-12-02T21:00:00.003Z</td>\n",
       "      <td>Long Beach</td>\n",
       "      <td>CA</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>38985694</td>\n",
       "      <td>1013324522</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-12-01 17:31:05.504000+00:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>426775474</td>\n",
       "      <td>2012-12-02T05:30:00.003Z</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>CA</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>285</th>\n",
       "      <td>71688472</td>\n",
       "      <td>3084061084</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-19 19:28:16.788000+00:00</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1022228390</td>\n",
       "      <td>2012-11-20T01:30:00.003Z</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>CA</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>286</th>\n",
       "      <td>71688472</td>\n",
       "      <td>3175036170</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-19 19:28:30.868000+00:00</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2916504903</td>\n",
       "      <td>2012-11-21T04:00:00.003Z</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>CA</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>167</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 115 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         user       event  invited                         timestamp  \\\n",
       "130  29002074  3743521539        0  2012-11-17 19:43:28.249000+00:00   \n",
       "164  38985694   364913652        0  2012-12-01 17:31:05.504000+00:00   \n",
       "166  38985694  1013324522        0  2012-12-01 17:31:05.504000+00:00   \n",
       "285  71688472  3084061084        0  2012-11-19 19:28:16.788000+00:00   \n",
       "286  71688472  3175036170        0  2012-11-19 19:28:30.868000+00:00   \n",
       "\n",
       "     interested  not_interested     user_id                start_time  \\\n",
       "130           0               0  4145324389  2013-01-01T03:00:00.003Z   \n",
       "164           0               0   405625535  2012-12-02T21:00:00.003Z   \n",
       "166           0               0   426775474  2012-12-02T05:30:00.003Z   \n",
       "285           1               0  1022228390  2012-11-20T01:30:00.003Z   \n",
       "286           1               0  2916504903  2012-11-21T04:00:00.003Z   \n",
       "\n",
       "            city state   ...    c_92 c_93  c_94  c_95  c_96  c_97  c_98  c_99  \\\n",
       "130    Elizabeth    NJ   ...       0    0     0     0     0     0     0     0   \n",
       "164   Long Beach    CA   ...       0    0     2     0     0     0     0     0   \n",
       "166  Los Angeles    CA   ...       0    0     0     0     0     0     0     0   \n",
       "285  Los Angeles    CA   ...       0    0     0     0     0     0     0     0   \n",
       "286  Los Angeles    CA   ...       0    1     0     0     0     0     0     1   \n",
       "\n",
       "     c_100  c_other  \n",
       "130      0       73  \n",
       "164      0      111  \n",
       "166      0       94  \n",
       "285      0       19  \n",
       "286      2      167  \n",
       "\n",
       "[5 rows x 115 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user</th>\n",
       "      <th>event</th>\n",
       "      <th>invited</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>user_id</th>\n",
       "      <th>start_time</th>\n",
       "      <th>city</th>\n",
       "      <th>state</th>\n",
       "      <th>zip</th>\n",
       "      <th>country</th>\n",
       "      <th>...</th>\n",
       "      <th>c_92</th>\n",
       "      <th>c_93</th>\n",
       "      <th>c_94</th>\n",
       "      <th>c_95</th>\n",
       "      <th>c_96</th>\n",
       "      <th>c_97</th>\n",
       "      <th>c_98</th>\n",
       "      <th>c_99</th>\n",
       "      <th>c_100</th>\n",
       "      <th>c_other</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2061</th>\n",
       "      <td>847928412</td>\n",
       "      <td>308894612</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-17 02:23:04.053000+00:00</td>\n",
       "      <td>2593938859</td>\n",
       "      <td>2012-11-21T02:00:00.003Z</td>\n",
       "      <td>Lawrence</td>\n",
       "      <td>MA</td>\n",
       "      <td>01840-1302</td>\n",
       "      <td>United States</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2563</th>\n",
       "      <td>1039053975</td>\n",
       "      <td>3084061084</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-15 04:34:57.682000+00:00</td>\n",
       "      <td>1022228390</td>\n",
       "      <td>2012-11-20T01:30:00.003Z</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>CA</td>\n",
       "      <td>90017</td>\n",
       "      <td>United States</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2810</th>\n",
       "      <td>1119929505</td>\n",
       "      <td>3764710330</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-12-07 14:31:35.824000+00:00</td>\n",
       "      <td>4216873862</td>\n",
       "      <td>2012-12-08T00:00:00.001Z</td>\n",
       "      <td>Costa Mesa</td>\n",
       "      <td>CA</td>\n",
       "      <td>92626</td>\n",
       "      <td>United States</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3098</th>\n",
       "      <td>1260240845</td>\n",
       "      <td>3677554347</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-29 19:33:15.244000+00:00</td>\n",
       "      <td>1474144414</td>\n",
       "      <td>2012-12-01T00:00:00.001Z</td>\n",
       "      <td>Palo Alto</td>\n",
       "      <td>CA</td>\n",
       "      <td>94043-4684</td>\n",
       "      <td>United States</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4705</th>\n",
       "      <td>1939233431</td>\n",
       "      <td>3743521539</td>\n",
       "      <td>0</td>\n",
       "      <td>2012-11-10 04:21:36.796000+00:00</td>\n",
       "      <td>4145324389</td>\n",
       "      <td>2013-01-01T03:00:00.003Z</td>\n",
       "      <td>Elizabeth</td>\n",
       "      <td>NJ</td>\n",
       "      <td>07201</td>\n",
       "      <td>United States</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 113 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            user       event  invited                         timestamp  \\\n",
       "2061   847928412   308894612        0  2012-11-17 02:23:04.053000+00:00   \n",
       "2563  1039053975  3084061084        0  2012-11-15 04:34:57.682000+00:00   \n",
       "2810  1119929505  3764710330        0  2012-12-07 14:31:35.824000+00:00   \n",
       "3098  1260240845  3677554347        0  2012-11-29 19:33:15.244000+00:00   \n",
       "4705  1939233431  3743521539        0  2012-11-10 04:21:36.796000+00:00   \n",
       "\n",
       "         user_id                start_time         city state         zip  \\\n",
       "2061  2593938859  2012-11-21T02:00:00.003Z     Lawrence    MA  01840-1302   \n",
       "2563  1022228390  2012-11-20T01:30:00.003Z  Los Angeles    CA       90017   \n",
       "2810  4216873862  2012-12-08T00:00:00.001Z   Costa Mesa    CA       92626   \n",
       "3098  1474144414  2012-12-01T00:00:00.001Z    Palo Alto    CA  94043-4684   \n",
       "4705  4145324389  2013-01-01T03:00:00.003Z    Elizabeth    NJ       07201   \n",
       "\n",
       "            country   ...     c_92  c_93  c_94  c_95  c_96  c_97  c_98  c_99  \\\n",
       "2061  United States   ...        0     0     0     0     0     0     0     0   \n",
       "2563  United States   ...        0     0     0     0     0     0     0     0   \n",
       "2810  United States   ...        0     0     0     0     0     0     0     0   \n",
       "3098  United States   ...        0     0     0     0     0     0     1     0   \n",
       "4705  United States   ...        0     0     0     0     0     0     0     0   \n",
       "\n",
       "      c_100  c_other  \n",
       "2061      0       23  \n",
       "2563      0       19  \n",
       "2810      0       49  \n",
       "3098      0       55  \n",
       "4705      0       73  \n",
       "\n",
       "[5 rows x 113 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_test_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/model_selection/_split.py:2069: FutureWarning: From version 0.21, test_size will always complement train_size unless both are specified.\n",
      "  FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "y_train = user_train_data.interested.values\n",
    "#X_train = user_train_data.drop([\"interested\"],axis=1).values\n",
    "X_train = user_train_data.drop([\"not_interested\",\"interested\",\"timestamp\",\"start_time\",\"zip\",\"state\",\"country\",\"city\"],axis=1).values\n",
    "X_test_data=user_test_data.drop([\"timestamp\",\"start_time\",\"zip\",\"state\",\"country\",\"city\"],axis=1).values\n",
    "# 将训练集合拆分成训练集和校验集，在校验集上找到最佳的模型超参数（PCA的维数）\n",
    "X_train_part, X_val, y_train_part, y_val = train_test_split(X_train,y_train, train_size = 0.8,random_state = 0)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 226 entries, 130 to 15376\n",
      "Columns: 115 entries, user to c_other\n",
      "dtypes: float64(2), int64(107), object(6)\n",
      "memory usage: 204.8+ KB\n"
     ]
    }
   ],
   "source": [
    "user_train_data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 一个参数点（聚类数据为K）的模型，在校验集上评价聚类算法性能\n",
    "def K_cluster_analysis(K, X_train, y_train, X_val, y_val):\n",
    "    start = time.time()\n",
    "    \n",
    "    print(\"K-means begin with clusters: {}\".format(K));\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    mb_kmeans = MiniBatchKMeans(n_clusters = K)\n",
    "    mb_kmeans.fit(X_train)\n",
    "    \n",
    "    # 在训练集和测试集上测试\n",
    "    #y_train_pred = mb_kmeans.fit_predict(X_train)\n",
    "    y_val_pred = mb_kmeans.predict(X_val)\n",
    "    \n",
    "    #以前两维特征打印训练数据的分类结果\n",
    "    #plt.scatter(X_train[:, 0], X_train[:, 1], c=y_pred)\n",
    "    #plt.show()\n",
    "\n",
    "    # K值的评估标准\n",
    "    #常见的方法有轮廓系数Silhouette Coefficient和Calinski-Harabasz Index\n",
    "    #这两个分数值越大则聚类效果越好\n",
    "    #CH_score = metrics.calinski_harabaz_score(X_train,mb_kmeans.predict(X_train))\n",
    "    CH_score = metrics.silhouette_score(X_train,mb_kmeans.predict(X_train))\n",
    "    \n",
    "    #也可以在校验集上评估K\n",
    "    v_score = metrics.v_measure_score(y_val, y_val_pred)\n",
    "    \n",
    "    end = time.time()\n",
    "    print(\"CH_score: {}, time elaps:{}\".format(CH_score, int(end-start)))\n",
    "    print(\"v_score: {}\".format(v_score))\n",
    "    \n",
    "    return CH_score,v_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "CH_score: 0.2917424359523963, time elaps:0\n",
      "v_score: 0.12872306753349602\n",
      "K-means begin with clusters: 20\n",
      "CH_score: 0.30890400988512345, time elaps:0\n",
      "v_score: 0.13401834604819732\n",
      "K-means begin with clusters: 30\n",
      "CH_score: 0.33776822382212535, time elaps:0\n",
      "v_score: 0.1565636927889111\n",
      "K-means begin with clusters: 40\n",
      "CH_score: 0.31644742911474066, time elaps:0\n",
      "v_score: 0.22107998878996035\n",
      "K-means begin with clusters: 50\n",
      "CH_score: 0.33798384738721543, time elaps:0\n",
      "v_score: 0.18354125237681587\n",
      "K-means begin with clusters: 60\n",
      "CH_score: 0.3190083283876342, time elaps:0\n",
      "v_score: 0.23028358954542305\n",
      "K-means begin with clusters: 70\n",
      "CH_score: 0.2945843033415203, time elaps:0\n",
      "v_score: 0.21841785868601205\n",
      "K-means begin with clusters: 80\n",
      "CH_score: 0.281447757281516, time elaps:0\n",
      "v_score: 0.20385463073942633\n",
      "K-means begin with clusters: 90\n",
      "CH_score: 0.27604718344145807, time elaps:0\n",
      "v_score: 0.22551518748469607\n",
      "K-means begin with clusters: 100\n",
      "CH_score: 0.26682891612358, time elaps:0\n",
      "v_score: 0.2211557637737376\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = [10, 20, 30,40,50,60,70,80,90,100]\n",
    "CH_scores = []\n",
    "v_scores = []\n",
    "for K in Ks:\n",
    "    ch,v = K_cluster_analysis(K, X_train_part, y_train_part, X_val, y_val)\n",
    "    CH_scores.append(ch)\n",
    "    v_scores.append(v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f619efa04a8>]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3XeclOXV//HPoVtiRx8FBFQsKAZ0JWo0RkXFqGAHooIGxAKxYMOKIjY0VoiCqLHEYFeiQWKLj5qILAJKEQEb2Fhj4SeItPP748w+Driws+zs3FO+79eLl8w99+ycGYcz1173uc5l7o6IiJSGekkHICIiuaOkLyJSQpT0RURKiJK+iEgJUdIXESkhSvoiIiVESV9EpIQo6YuIlBAlfRGREtIg6QBWtdlmm3mrVq2SDkNEpKBMnDjxK3dvWt15GSV9M+sM3AbUB0a5+/Wr3H860A9YDnwP9HX36Wn3bw1MB65095vW9FytWrWivLw8k7BERCTFzD7O5Lxqp3fMrD4wHDgUaAv0MLO2q5z2sLu3c/f2wFDg5lXuvxkYm0lAIiJSdzKZ0+8IzHb3D9x9CTAa6Jp+grsvSLu5HvB/XdzM7EjgQ2Ba7cMVEZHayCTpNwPmpt2elzq2EjPrZ2ZziJH+Walj6wMXAVfVPlQREamtrFXvuPtwd9+WSPKXpQ5fCdzi7t+v6bFm1tfMys2svKKiIlshiYjIKjK5kPsp0CLtdvPUsdUZDdyZ+vuvgGPNbCiwEbDCzBa7+7D0B7j7SGAkQFlZmRr8i4jUkUyS/gSgjZm1JpJ9d+D36SeYWRt3n5W6eRgwC8Dd900750rg+1UTvoiI5E61Sd/dl5lZf2AcUbJ5r7tPM7PBQLm7jwH6m1knYCnwDdCr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d5+BRokXZeVt4bJf1aMjMD7gFmuPvNaXeNAXql/t6LmOsvau5+sbs3d/dWxAW6l939BOAV4NjUaSXxXgC4+xfAXDPbIXXoQGA6JfjZSPkE2NPM1k39u6l8P0ry85FmdZ+HMUDPVBXPnsB3adNAa02Ls2rJzPYBXgPe5ad57EuIef1Hga2JrqHHu/vXiQSZADP7LXC+ux9uZtsQI/9NgEnAie7+Y5Lx5YqZtQdGAY2AD4BTiMFWSX42zOwqoBtR9TYJ6EPMU5fE58PM/gb8luim+SUwCHiaKj4PqS/GYcQU2CLgFHcvr3UMSvoiIqVD0zsiIiVESV9EpIQo6YuIlBAlfRGREqKkLyJSQpT0RURKiJK+iEgJUdIXESkh/x/U3o8/q9KtJAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "# 绘制不同PCA维数下模型的性能，找到最佳模型／参数（分数最高）\n",
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f619eeacdd8>]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAIABJREFUeJzt3Xd4VGX6xvHvk4QQaqSEXkIvAgKGjnTsBKSjINjQtSCuCuu66xZdLxXLqj9WRRRDE6kKroATg4AGkCCEKkImAUIEI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QxpjnQEXhMRJoDfwK+McY0Ar5x37aLJ4EdBW6/CrxljGkIHAUesCSVNd4GlhljmgI3kP+82PLYEJGawDggxhjTAggFhmOv4+MT4NaLll3ueLgNaOT+Ggu855UExhj98uIX8AXQF9gJVHcvqw7stDpbMX3/tdwHbi/gS0DI/2OTMPf9nYDlVucspuciEkjFfe6swHK7Hhs1gX1ARfI/te9L4Ba7HR9ANLC1sOMB+AAYcan1ivKl7/S9SESigTbAOqCqMeYX910HgKoWxSpu/wYmAHnu25WALGOMy307nfwffjuoB2QC09zDXVNFpAw2PTaMMfuB14G9wC/Ab8AG7Ht8nHO54+Hci+Q5XnlutPS9RETKAguA8caYYwXvM/kv00F/mZSI3AkcMsZssDqLnwgD2gLvGWPaACe4aCjHLscGgHusuj/5L4Y1gDL8fqjD1orjeNDS9wIRKUF+4c8yxix0Lz4oItXd91cHDlmVrxh1AWJFJA2YQ/4Qz9vAdSIS5l6nFrDfmnjFLh1IN8asc9+eT/6LgB2PDYA+QKoxJtMYcxZYSP4xY9fj45zLHQ/7gdoF1vPKc6OlX0QiIsBHwA5jzJsF7loMjHb/ezT5Y/1BzRjznDGmljEmmvwTdAnGmHuAFcBg92q2eC4AjDEHgH0i0sS9qDewHRseG257gY4iUtr9c3Pu+bDl8VHA5Y6HxcC97qt4OgK/FRgGumb6x1lFJCJdgdXAFv43jv1n8sf15wJ1yJ81dKgx5oglIS0gIj2AZ4wxd4pIffLf+VcENgIjjTE5VuYrLiLSGpgKhANO4D7y32zZ8tgQkX8Aw8i/6m0j8CD549S2OD5E5FOgB/mzaR4E/gZ8ziWOB/cL4/+RPwR2ErjPGJNU5Axa+kopZR86vKOUUjaipa+UUjaipa+UUjaipa+UUjaipa+UUjaipa+UUjaipa+UUjaipa+UUjby/4GUGtCffutbAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(Ks, np.array(v_scores), 'g-')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#best k is  K-means begin with clusters: 40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "#K-means begin with clusters: 40\n",
    "#CH_score: 0.3099709880690662, time elaps:0\n",
    "#v_score: 0.2176434986835596\n",
    "#K-means,在训练集上训练\n",
    "\n",
    "#the best k is 40 \n",
    "mb_kmeans = MiniBatchKMeans(n_clusters = 40)\n",
    "mb_kmeans.fit(X_train)\n",
    "    \n",
    "# 在训练集和测试集上测试\n",
    "#y_train_pred = mb_kmeans.fit_predict(X_train)\n",
    "y_val_pred = mb_kmeans.predict(X_val)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "#use pvc\n",
    "\n",
    "from sklearn import svm\n",
    "from sklearn.decomposition import PCA\n",
    "\n",
    "# 一个参数点（PCA维数为n）的模型训练和测试，得到该参数下模型在校验集上的预测性能\n",
    "def n_component_analysis(n, X_train, y_train, X_val, y_val):\n",
    "    start = time.time()\n",
    "    \n",
    "    pca = PCA(n_components=n)\n",
    "    print(\"PCA begin with n_components: {}\".format(n));\n",
    "    pca.fit(X_train)\n",
    "    \n",
    "    # 在训练集和测试集降维 \n",
    "    X_train_pca = pca.transform(X_train)\n",
    "    X_val_pca = pca.transform(X_val)\n",
    "    \n",
    "    # 利用SVC训练\n",
    "    print('SVC begin')\n",
    "    clf1 = svm.SVC()\n",
    "    clf1.fit(X_train_pca, y_train)\n",
    "    \n",
    "    # 返回accuracy\n",
    "    accuracy = clf1.score(X_val_pca, y_val)\n",
    "    \n",
    "    end = time.time()\n",
    "    print(\"accuracy: {}, time elaps:{}\".format(accuracy, int(end-start)))\n",
    "    return accuracy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PCA begin with n_components: 0.7\n",
      "SVC begin\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7015151515151514\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.703030303030303\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7045454545454545\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.706060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7075757575757575\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.709090909090909\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7106060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.712121212121212\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7136363636363636\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7151515151515151\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7166666666666667\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7181818181818181\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7196969696969696\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7212121212121212\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7227272727272727\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7242424242424242\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7257575757575757\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7272727272727272\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7287878787878788\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7303030303030302\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7318181818181818\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7333333333333333\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7348484848484849\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7363636363636363\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7378787878787878\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7393939393939394\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7409090909090909\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7424242424242424\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7439393939393939\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7454545454545454\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.746969696969697\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7484848484848484\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.75\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7515151515151515\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7530303030303029\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7545454545454545\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.756060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7575757575757576\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.759090909090909\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7606060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7621212121212121\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7636363636363636\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7651515151515151\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7666666666666666\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7681818181818182\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7696969696969697\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7712121212121212\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7727272727272727\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7742424242424242\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7757575757575758\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7772727272727272\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7787878787878788\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7803030303030303\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7818181818181817\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7833333333333333\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7848484848484848\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7863636363636364\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7878787878787878\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7893939393939393\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7909090909090909\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7924242424242424\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.793939393939394\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7954545454545454\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7969696969696969\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7984848484848485\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.7999999999999999\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8015151515151515\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.803030303030303\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8045454545454546\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.806060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8075757575757575\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8090909090909091\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8106060606060606\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8121212121212121\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8136363636363636\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8151515151515152\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8166666666666667\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8181818181818181\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8196969696969697\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8212121212121212\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8227272727272728\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8242424242424242\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8257575757575757\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8272727272727273\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8287878787878787\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8303030303030303\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8318181818181818\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8333333333333333\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8348484848484848\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8363636363636363\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8378787878787879\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8393939393939394\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8409090909090908\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8424242424242424\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8439393939393939\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8454545454545455\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8469696969696969\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.8484848484848484\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n",
      "PCA begin with n_components: 0.85\n",
      "SVC begin\n",
      "accuracy: 0.717391304347826, time elaps:0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n",
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（PCA维数）搜索范围\n",
    "n_s = np.linspace(0.70, 0.85, num=100)\n",
    "accuracy = []\n",
    "for n in n_s:\n",
    "    tmp = n_component_analysis(n, X_train_part, y_train_part, X_val, y_val)\n",
    "    accuracy.append(tmp)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f619ee30668>]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvDW2N/gAAE1tJREFUeJzt3X+s3Xd93/HnCweHIpThLBdUYsfxVkcBVpSsp94oy8o6GTymxd0PwU2HmnRT3Q0SiUhUC2LSmKtJpR0Lm/AftdSsGhKxqLUib6VzsqYRjDmSj1snYEd2jGmXa6rlFmJ1aTeMw3t/nO9tj09ufM/1PdfnmM/zIR35+/18P9/j17nXfp3v/Z5z7jdVhSSpDa+ZdgBJ0tVj6UtSQyx9SWqIpS9JDbH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": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制不同PCA维数下模型的性能，找到最佳模型／参数（分数最高）\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "plt.plot(n_s, np.array(accuracy), 'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PCA(copy=True, iterated_power='auto', n_components=0.75, random_state=None,\n",
       "  svd_solver='auto', tol=0.0, whiten=False)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#最佳模型参数\n",
    "pca = PCA(n_components=0.75)\n",
    "\n",
    "#根据最佳参数，在全体训练数据上重新训练模型\n",
    "pca.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pca.n_components_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.38097439, 0.34638805, 0.27263756])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pca.explained_variance_ratio_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#根据最佳参数，对全体训练数据降维\n",
    "X_train_pca = pca.transform(X_train)\n",
    "#根据最佳参数，对测试数据降维\n",
    "X_test_pca = pca.transform(X_test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/vincent/.local/lib/python3.6/site-packages/sklearn/svm/base.py:196: FutureWarning: The default value of gamma will change from 'auto' to 'scale' in version 0.22 to account better for unscaled features. Set gamma explicitly to 'auto' or 'scale' to avoid this warning.\n",
      "  \"avoid this warning.\", FutureWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
       "  decision_function_shape='ovr', degree=3, gamma='auto_deprecated',\n",
       "  kernel='rbf', max_iter=-1, probability=False, random_state=None,\n",
       "  shrinking=True, tol=0.001, verbose=False)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#在降维后的训练数据集上训练SVM分类器\n",
    "clf = svm.SVC()\n",
    "clf.fit(X_train_pca, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用在降维后的全体训练数据集上训练的模型对测试集进行测试\n",
    "y_predict = clf.predict(X_test_pca)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "#生成提交测试结果\n",
    "import pandas as pd\n",
    "df = pd.DataFrame(y_predict)\n",
    "df.columns=['interested']\n",
    "df.index+=1\n",
    "df.index.name = 'Imageid'\n",
    "df.to_csv('my_event.csv', header=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
